package com.jml.account.common.entity.utils;


import java.util.Iterator;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl;
import org.activiti.engine.task.Comment;

public class JumpTaskCmd implements Command<Comment> {
  protected String executionId;
  protected String activityId;

  public JumpTaskCmd(String executionId, String activityId) {
    this.executionId = executionId;
    this.activityId = activityId;
  }

  public Comment execute(CommandContext commandContext) {
    Iterator var3 = Context.getCommandContext().getTaskEntityManager().findTasksByExecutionId(this.executionId).iterator();

    while(var3.hasNext()) {
      TaskEntity taskEntity = (TaskEntity)var3.next();
      Context.getCommandContext().getTaskEntityManager().deleteTask(taskEntity, "jump", false);
    }

    ExecutionEntity executionEntity = Context.getCommandContext().getExecutionEntityManager().findExecutionById(this.executionId);
    ProcessDefinitionImpl processDefinition = executionEntity.getProcessDefinition();
    ActivityImpl activity = processDefinition.findActivity(this.activityId);
    executionEntity.executeActivity(activity);
    return null;
  }
}

